package com.ruoyi.worker.domain.workAttendance;

import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.uuid.IdUtils;
import lombok.Data;
import lombok.ToString;

import java.util.List;

/**
 * @ClassName AttendanceDailyInformation
 * @Description 长期工考勤每日汇总
 * @Author leizhang
 * Date 2021/11/18 10:50 下午
 * @Version 1.0
 **/
@Data
@ToString
public class AttendanceSumDailyRecord extends BaseEntity {
    private String id;
    /**
     * 班组id
     **/
    private int deptId;
    /**
     * 班次id
     **/
    private long shiftId;
    /**
     * 班次名称
     **/
    private String shiftName;
    /**
     * 班组名称
     **/
    private String deptName;
    /**
     * 考勤日期
     **/
    private String workTime;
    /**
     * 应出勤人数
     **/
    private int numberOfAttendance;
    /**
     * 实际出勤人数
     **/
    private int numberOfActualAttendance;
    /**
     * 异常(未打卡)人数
     **/
    private int numberOfAbnormal;
    /**
     * 普通迟到人数
     **/
    private int numberOfLate;
    /**
     * 一般迟到
     **/
    private int numberOfNormallyLate;
    /**
     * 严重迟到
     **/
    private int numberOfSeverelyLate;
    /**
     * 早退人数
     **/
    private int numberOfLeaveEarly;
    /**
     * 旷工人数
     **/
    private int numberOfAbsenteeism;
    /**
     * 休息人数
     **/
    private int numberOfRest;
    /**
     * 长期工考勤信息
     **/
    private List<AttendanceDailyRecord> attendanceDailyRecordList;

    //计算考勤汇总
    public void sumAttendance() {
        if (attendanceDailyRecordList.isEmpty()) {
            return;
        }
        for (AttendanceDailyRecord attendanceDailyRecord : attendanceDailyRecordList) {
            //未打卡的人数汇总
            if (attendanceDailyRecord.getAbnormalAttendance() == 1) {
                numberOfRest++;
            }
            if (attendanceDailyRecord.getAbnormalAttendance() == 7) {
                numberOfAbnormal++;
            }
            //普通迟到人数
            if (attendanceDailyRecord.getNormallyLate() > 0) {
                numberOfLate++;
            }
            //一般迟到人数
            if (attendanceDailyRecord.getUsuallyLate() > 0) {
                numberOfNormallyLate++;
            }
            //严重迟到人数
            if (attendanceDailyRecord.getSeverelyLate() > 0) {
                numberOfSeverelyLate++;
            }
            //早退人数
            if (attendanceDailyRecord.getLeaveEarly() > 0) {
                numberOfLeaveEarly++;
            }
            //旷工人数
            if (attendanceDailyRecord.getAbsenteeism() > 0) {
                numberOfAbsenteeism++;
            }
        }
        numberOfAttendance = attendanceDailyRecordList.size();
        numberOfActualAttendance = numberOfAttendance - numberOfAbnormal;
    }

    public AttendanceSumDailyRecord() {
    }

    public AttendanceSumDailyRecord( int deptId, String workTime, List<AttendanceDailyRecord> attendanceDailyRecordList) {
        this.id = IdUtils.fastSimpleUUID();
        this.deptId = deptId;
        this.workTime = workTime;
        this.attendanceDailyRecordList = attendanceDailyRecordList;
    }

    public AttendanceSumDailyRecord(String id, long shiftId, int deptId, String workTime, List<AttendanceDailyRecord> attendanceDailyRecordList) {
        this.id = id;
        this.shiftId = shiftId;
        this.deptId = deptId;
        this.workTime = workTime;
        this.attendanceDailyRecordList = attendanceDailyRecordList;
    }
}
